package com.yonyou.crm.bpub.detail.appctrl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.crm.bpub.detail.entity.DetailsVO;
import com.yonyou.crm.bpub.detail.rmitf.IDetailsRmService;
import com.yonyou.crm.common.exception.CrmMessageException;
import com.yonyou.crm.common.rest.util.ResponseUtil;

@RequestMapping("/{version}/*/{module}/details")
@RestController
public class AppDetailCtrl {
	
	@Autowired
	private IDetailsRmService service;
	
	@RequestMapping(value="/{id}", method = RequestMethod.GET)
	public Object getDetailData(@PathVariable("version") String version, @PathVariable("module") String module,@PathVariable("id") String id, HttpServletRequest request, HttpServletResponse response) throws CrmMessageException {
		
		if (id.equals(0)) {
			throw new CrmMessageException("获取对象不存在");
		}
		DetailsVO detailData = service.getDetailData(module, id);

		return ResponseUtil.getObject(detailData);
	}
}
